<template>
  <el-dialog
    :close-on-click-modal="false"
    :show-close="false"
    :title="details?'退款详情':'发货'"
    :visible.sync="isAdd"
  >
    <el-form v-if="details">
      <div class="user-info-item">
        <span>订单号：</span>
        <span>{{refundDataDetail.order_sn}}</span>
      </div>
      <div class="user-info-item">
        <span>退款单号：</span>
        <span>{{refundDataDetail.refund_sn}}</span>
      </div>
      <div class="user-info-item">
        <span>渠道商退款订单号：</span>
        <span>{{refundDataDetail.orderInfo.merchant_order_sn}}</span>
      </div>
      <div class="user-info-item">
        <span>申请退款金额：</span>
        <span>{{refundDataDetail.refund_expect}}</span>
      </div>
      <div class="user-info-item">
        <span>实际退款金额：</span>
        <span>{{refundDataDetail.refund_amount}}</span>
      </div>
      <div class="user-info-item">
        <span>退款原因：</span>
        <span>{{refundDataDetail.reason}}</span>
      </div>
      <div class="user-info-item">
        <span>申请退款时间：</span>
        <span>{{refundDataDetail.create_time}}</span>
      </div>
      <div class="user-info-item">
        <span>渠道商审核人：</span>
        <span>{{refundDataDetail.manage.username}}</span>
      </div>
      <div class="user-info-item">
        <span>渠道商审核时间：</span>
        <span>{{refundDataDetail.channel_time}}</span>
      </div>
      <div class="user-info-item">
        <span>渠道商审核意见：</span>
        <span>{{refundDataDetail.channel_reject_reason}}</span>
      </div>
      <div class="user-info-item">
        <span>总平台审核时间：</span>
        <span>{{refundDataDetail.platform_time}}</span>
      </div>
      <div class="user-info-item">
        <span>平台审核人：</span>
        <span>{{refundDataDetail.manage.username}}</span>
      </div>
      <div class="user-info-item">
        <span>平台审核意见：</span>
        <span>{{refundDataDetail.reject_reason}}</span>
      </div>
    </el-form>
    
    <el-form v-else
      ref="ruleForm"
      :model="form"
      label-width="120px"
      size="small"
      class="form-box"
    >
      <el-form-item label="快递名称" prop="shipping_company">
       <el-select v-model="form.shipping_company" clearable placeholder="快递名称">
        <el-option label="韵达快递" value="韵达快递"></el-option>
        <el-option label="中通快递" value="中通快递"></el-option>
        <el-option label="申通快递" value="申通快递"></el-option>
        <el-option label="顺丰快递" value="顺丰快递"></el-option>
        <el-option label="邮政快递" value="邮政快递"></el-option>
        <el-option label="天天快递" value="天天快递"></el-option>
      </el-select>
      </el-form-item>
      <el-form-item label="快递单号" prop="shipping_no">
        <el-input type="text" v-model="form.shipping_no" placeholder=""></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" v-if="details" class="dialog-footer">
      <el-button type="primary" @click="restShipping()" size="small">确定</el-button>
    </span>
    <span slot="footer" v-else class="dialog-footer">
      <el-button @click="restShipping()" size="small">取消</el-button>
      <el-button @click="submitFormAdd('ruleForm')" type="primary" size="small">发货</el-button>
    </span>
  </el-dialog>
</template>

<script lang="ts">
import { Component, Vue, Prop, Provide } from "vue-property-decorator";

import orderApi from "@/api/order";
@Component({
  components: {}
})
export default class userEditDialog extends Vue {
  // 属性或参数中使用 ！：表示强制解析（告诉typescript编译器，这里一定有值），常用于vue-decorator中的@Prop
  check:boolean = true//防重复提交
  @Prop(Boolean) isAdd!: boolean;
  @Prop(Boolean) details!: boolean;
  @Prop(Object) form!: {
    id:number,
    shipping_company: string,
    shipping_no: string,
  };
  @Prop(Object) refundDataDetail!: {};
  
  // 提交deliverGoods
  submitFormAdd(formName: any) {
    (this.$refs[formName] as any).validate((valid: boolean) => {
      if (valid) {
        if(this.check) {
          let _this = this
          _this.check = false
          orderApi.deliverOrder(_this.form)
          .then((res: any) => {
            if(res.data.status){
              _this.$message({
                message: '操作成功',
                type: "success"
              });
              _this.$emit("closeDialog");
              _this.$emit("loadData")
              setTimeout(function(){
                _this.check = true
              },3000)
            }else{
              _this.$message({
                message: res.data.msg,
                type: "error"
              });
              _this.check = true
            }
          });
        }
          
      }
    });
  }
   
   restShipping(){
     this.form.shipping_company = '';
     this.form.shipping_no = '';
     this.$emit('closeDialog')
   }
  created() {
  }
}
</script>

<style lang="scss" scoped>
.form-box { 
  .el-input,
  .el-select {
    width: 200px !important;
  }
}
</style>
